package ClassData;

import java.nio.ByteBuffer;

import ClassData.Visitor.IVisitor;
import ClassData.Visitor.IVisitorElement;

/**
 * Holds informations about exceptions, 
 * that may be thrown by a method.
 * @note changed by Dominik Ollesz
 */
public class AttributeInfo_Exceptions extends AttributeInfo implements IVisitorElement {
	
	short [] exceptionTable;	
	
	public AttributeInfo_Exceptions(ByteBuffer dataBuffer) {
		int exceptionCounter;
		
		exceptionTable = new short [dataBuffer.getShort()];
		
		for (exceptionCounter=0;exceptionCounter<exceptionTable.length ;exceptionCounter++) {
			exceptionTable[exceptionCounter]=dataBuffer.getShort();
		}
	}
	
	/**
	 * Get length of exception table.
	 * @author Dominik Ollesz
	 */
	public int getExcetionsSize() {
		int size = exceptionTable.length; 
		return(size); 
	}
	
	/**
	 * Get current exceptions.
	 * @author Dominik Ollesz
	 */
	public short[] getExceptions() {
		return exceptionTable;
	}
	
	@Override
	public void receive_Visitor(IVisitor visitor) {
		visitor.visit_AttributeInfo_Excetions(this);
	}
	
}
